package customer.zspt.cn.customer.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Administrator on 2018/7/24 0024.
 */

public class TimestampToBj {
    public static String getBeijingTime(long time) {
        String Truetime = "";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        String format = sdf.format(new Date(time));
        String[] Hssplit = format.split(" ");
        String[] datasplit = Hssplit[0].split("-");
        SimpleDateFormat now = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        long nowTime = System.currentTimeMillis();
        String Nowformat = sdf.format(new Date(nowTime));
        String[] Nwsplit = Nowformat.split(" ");
        String[] Ndatasplit = Nwsplit[0].split("-");
        if (Hssplit[0].equals(Nwsplit[0])) {
            Truetime += Hssplit[1];
        } else if (Integer.parseInt(Ndatasplit[2]) - Integer.parseInt(datasplit[2]) == 1) {
            Truetime += "昨天 " + Hssplit[1];
        } else if (Integer.parseInt(Ndatasplit[2]) - Integer.parseInt(datasplit[2]) == 2) {
            Truetime += "前天 " + Hssplit[1];
        } else {
            Truetime += format;
        }
        return Truetime;
    }
    public static String getTime(long time) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String format = sdf.format(new Date(time));
        return format;
    }
    public static String getTimeADate(long time) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-kk-mm");
        String format = sdf.format(new Date(time));
        return format;
    }
}
